﻿namespace Blaze.Editor.Dev.DevPanels
{
    using EditorOnly;
    using UnityEditor;
    using UnityEngine;

    /// <summary>
    /// 目录快捷方式功能面板。
    /// </summary>
    public class DirectoryShortcutDevPanel : DevPanel
    {
        /// <summary>
        /// 获取面板上显示的功能名称。
        /// </summary>
        public override string Name => "目录";

        /// <summary>
        /// 获取开发功能面板的显示优先级。
        /// </summary>
        public override int Priority => 6666;

        /// <summary>
        /// 当需要绘制面板时调用此方法。
        /// </summary>
        public override void OnGUI()
        {
            EditorGUILayout.BeginVertical();
            if (GUILayout.Button("/ - 工程根目录", mButtonStyle))
                ExplorerUtility.Show(ProjectPath.Root, true);

            GUILayout.Space(8);

            if (GUILayout.Button("Configs - 配置", mButtonStyle))
                ExplorerUtility.Show(ProjectPath.Get("Configs"), true);

            GUILayout.Space(8);

            if (GUILayout.Button("PersistentData - 本地数据", mButtonStyle))
                EditorUtility.RevealInFinder(ProjectPath.Get("PersistentData"));

            GUILayout.Space(8);

            if (GUILayout.Button("Lua - 脚本数据", mButtonStyle))
                ExplorerUtility.Show(ProjectPath.Get("Lua"), true);

            GUILayout.Space(8);

            if (GUILayout.Button("Build - 构建结果", mButtonStyle))
                ExplorerUtility.Show(ProjectPath.Get("Build"), true);

            EditorGUILayout.EndHorizontal();
        }

        /// <summary>
        /// 当面板需要初始化的时候调用。
        /// </summary>
        protected override void OnInitialize()
        {
            base.OnInitialize();
            mButtonStyle = new GUIStyle(GUISkinManager.Skin.button)
            {
                alignment = TextAnchor.MiddleRight
            };
        }

        private GUIStyle mButtonStyle;
    }
}